package io.chenglicun.modules.clc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.chenglicun.common.service.impl.CrudServiceImpl;
import io.chenglicun.common.utils.ConvertUtils;
import io.chenglicun.modules.clc.dao.ClcMapNodeCoordinateDao;
import io.chenglicun.modules.clc.dto.ClcMapNodeCoordinateDTO;
import io.chenglicun.modules.clc.entity.ClcMapNodeCoordinateEntity;
import io.chenglicun.modules.clc.service.ClcMapNodeCoordinateService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * 数字地图节点经纬度坐标
 *
 * @author HB 137664951@qq.com
 * @since 1.0 2023-11-06
 */
@Service
public class ClcMapNodeCoordinateServiceImpl extends CrudServiceImpl<ClcMapNodeCoordinateDao, ClcMapNodeCoordinateEntity, ClcMapNodeCoordinateDTO> implements ClcMapNodeCoordinateService {

    @Override
    public QueryWrapper<ClcMapNodeCoordinateEntity> getWrapper(Map<String, Object> params){
        QueryWrapper<ClcMapNodeCoordinateEntity> wrapper = new QueryWrapper<>();


        return wrapper;
    }

    @Override
    public List<ClcMapNodeCoordinateDTO> getByInfoIds(Long... ids) {
        List<ClcMapNodeCoordinateEntity> entities = baseDao.selectList(new QueryWrapper<ClcMapNodeCoordinateEntity>()
                .lambda().in(ClcMapNodeCoordinateEntity::getMapNodeInfoId, Arrays.asList(ids))
                .orderByAsc(ClcMapNodeCoordinateEntity::getNo));
        return ConvertUtils.sourceToTarget(entities, ClcMapNodeCoordinateDTO.class);
    }

    @Override
    @Transactional
    public void deleteByInfoIds(Long... ids) {
        baseDao.delete(new QueryWrapper<ClcMapNodeCoordinateEntity>()
                .lambda().in(ClcMapNodeCoordinateEntity::getMapNodeInfoId, Arrays.asList(ids)));
    }
}